import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter_syt/starter/i18n/app_localizations.dart';

import '../../channel_apis.dart';
import '../../starter/app_context.dart';
import '../../starter/processor.dart';

class StrResManager {
  // static List<String> _keys = [
  //   "home",
  //   "match",
  //   "info",
  //   "mine",
  //   "login_text_title",
  //   "login_input_hint",
  //   "login_send_code",
  //   "login_third_part",
  //   "login_by_wechat",
  //   "login_by_facebook",
  //   "login_by_apple",
  //   "login_verify_code_reminder",
  //   "login_verify_code_error_reminder",
  //   "login_button_reminder_prefix",
  //   "login_button_reminder_suffix",
  //   "login_resend_verification_code",
  //   "mine_un_login_label",
  //   "mine_login_edit",
  //   "account_binding",
  //   "about_go_chengdu",
  //   "clear_cache",
  //   "privacy_policy",
  //   "quit",
  //   "more",
  // ];
  //
  // static Map<String, String> _stringResource = <String, String>{};

  static String getStringByName(BuildContext context, String name) {
    try {
      var value = AppLocalizations.of(context).localString(name);
      return value;
    } catch (e) {
      return name;
    }
  }

  StrResManager._();
}

class LocalizationProcessor with Processor<List<String>> {
  @override
  Future<void> postProcessor(AppContext appContext, [dynamic param]) async {
    // var result =
    //     await appContext.channelApi.obtainStrResource(StrResManager._keys);
    // print("sss --- $result");
    // for (String each in result.keys) {
    //   StrResManager._stringResource[each] = "${result[each] ?? ''}";
    // }
    return Future.value();
  }
}
